# Reference: <https://postmarketos.org/vendorkernel>
# Kernel config based on: arch/arm/configs/bcm21664_hawaii_ss_kyleprods_rev00_lineage_defconfig

pkgname=linux-samsung-kyleprods
pkgver=3.4.113
pkgrel=1
pkgdesc="Samsung Galaxy S Duos 2 kernel fork"
arch="armv7"
_carch="arm"
_flavor="samsung-kyleprods"
url="https://kernel.org"
license="GPL-2.0-only"
options="!strip !check !tracedeps pmb:cross-native"
makedepends="bash bc bison devicepkg-dev elfutils-dev flex gcc6 gmp-dev installkernel linux-headers openssl-dev perl sed"

# Compiler: GCC 6 (untested with newer versions)
if [ "${CC:0:5}" != "gcc6-" ]; then
	CC="gcc6-$CC"
	CROSS_COMPILE="gcc6-$CROSS_COMPILE"
fi

# Source
_repository="android_kernel_samsung_kyleproxx"
_commit="026cf3b3e97ec40aa1c0c52837a318725786f05a"
_config="config-$_flavor.$arch"
source="
	$pkgname-$_commit.tar.gz::https://github.com/Samsung-KYLEPROXX/$_repository/archive/$_commit.tar.gz
	$_config
	00_return_address.patch
	02_screen_reset.patch
	gcc10-extern_YYLOC_global_declaration.patch
"
builddir="$srcdir/$_repository-$_commit"
_outdir="out"

prepare() {
	default_prepare
	. downstreamkernel_prepare
}

build() {
	unset LDFLAGS
	make O="$_outdir" ARCH="$_carch" CC="${CC:-gcc}" \
		KBUILD_BUILD_VERSION="$((pkgrel + 1 ))-postmarketOS"
}

package() {
	downstreamkernel_package "$builddir" "$pkgdir" "$_carch" "$_flavor" "$_outdir"
}

sha512sums="b66ab7d8ed557ed095b059beb7b37d196a7290e6c8364560126a94f696718c4a61f99b1e21700d9a4b50c569243e4e2cbfc9fbd9d9517ca49cfa32f31525c27f  linux-samsung-kyleprods-026cf3b3e97ec40aa1c0c52837a318725786f05a.tar.gz
4d6d8b1ea147930040e62febae8a5953c3375f57a7373c25431e02faff62f8952716c9d4b4d8a7b0a8e83b5c3303d812821790422160352071fc061762f6039a  config-samsung-kyleprods.armv7
c40eaa11547f5bc2b1ff965506bdfe3015ff16e4b5ad9ccb3b8134ceafd1d32407c4ef2b213e02e036ce1e9bdcbfe768dff7d4b054bec77705a176c1f783b6f5  00_return_address.patch
c0a59be648ef646650c83b5d135daa05aae300c7ad5056d49f1b3f9967c4d7f337b0ddb8ae319b11e43c17aaf5fc9dcc9724463d265c1d765dc85c86f612f4ea  02_screen_reset.patch
2b48f1bf0e3f70703d2cdafc47d5e615cc7c56c70bec56b2e3297d3fa4a7a1321d649a8679614553dde8fe52ff1051dae38d5990e3744c9ca986d92187dcdbeb  gcc10-extern_YYLOC_global_declaration.patch"
